//const BASE_URL = 'https://manniuwechat.lzcoke.com' //正式

const BASE_URL = 'https://shanfu.51fnt.com' //发布 https://shanfu.51fnt.com 测试 http://192.168.0.135:8083
//const BASE_URL = 'https://test.wechat.manniukeji.com' //测试
export const myRequest = (options) => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: BASE_URL + options.url,
			method: options.method || 'GET',
			data: options.method === 'GET' ? options.data : JSON.stringify(options.data),
			header: options.header,
			success: (res) => {
				let index = res.data.message.lastIndexOf("\/");
				let str = res.data.message.substring(index + 1, res.data.message.length);
				if (res.data.code != '200') {
					uni.showToast({
						title: str,
						icon: 'none',
						duration: 5000
					})
				}
				resolve(res)
			},
			fail: (err) => {
				uni.showToast({
					title: '网络加载失败!',
					icon: "none",
					duration: 3000
				})
				reject(err.data)
			}
		})
	})
}